package edu.bu.cs673.superkids123.parents.controller;

import java.util.List;

import edu.bu.cs673.superkids123.AbstractController;
import edu.bu.cs673.superkids123.AbstractFrame;
import edu.bu.cs673.superkids123.common.DataObjectAccess.ChildManager;
import edu.bu.cs673.superkids123.common.DataObjectAccess.ParentManager;
import edu.bu.cs673.superkids123.common.model.Child;
import edu.bu.cs673.superkids123.common.model.Parent;
import edu.bu.cs673.superkids123.common.model.User;
import edu.bu.cs673.superkids123.parents.view.CreateChildView;
import edu.bu.cs673.superkids123.parents.view.EditChildView;
import edu.bu.cs673.superkids123.parents.view.ParentSettingsView;
import edu.bu.cs673.superkids123.parents.view.ReportView;

/**
 * 
 * @author Brent Hepburn, Ethan Rubin
 */
public class ParentSettingsController extends AbstractController {

	public ParentSettingsController(AbstractFrame mainFrame) {
		super(mainFrame);
	}

	public void addChild() {
		getMainFrame().changeView(CreateChildView.class);
	}

	public void manageChild() {
		getMainFrame().changeView(EditChildView.class);
	}

	public void viewReport() {
		getMainFrame().changeView(ReportView.class);

	}

	public void deleteUser(User user) {
		if (user instanceof Child)
			ChildManager.DeleteChild((Child) user);
		else if (user instanceof Parent)
			ParentManager.deleteParent((Parent) user);
		getMainFrame().changeView(ParentSettingsView.class);
	}

	public List<Child> getAllChildren() {
		return ChildManager.getChildren();
	}

	public List<Parent> getAllParents() {
		return ParentManager.getParents();
	}

	public void editChild(Child child) {
		getMainFrame().getController(EditChildController.class).editUser(child);
	}
	
	public void addParent() {
		getMainFrame().getController(CreateParentController.class).createParent();
	}
	
	public void lockChild(Child toBeLocked){
		if (toBeLocked.isLocked() == true) {
			toBeLocked.setLocked(false);
			ChildManager.updateChild(toBeLocked);
			return;
		}
		if (toBeLocked.isLocked() == false) {
			toBeLocked.setLocked(true);
			ChildManager.updateChild(toBeLocked);
			return;
		}
		
		
	}

	public void editParent(Parent parent) {
		getMainFrame().getController(CreateParentController.class).editAccount(parent);
	}

}
